package com.ruoyi.workSafetyStandardization.service.impl;

import java.util.Date;
import java.util.List;

import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.workSafetyStandardization.mapper.MajorConfigMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.workSafetyStandardization.mapper.AccidentJudgeMapper;
import com.ruoyi.workSafetyStandardization.domain.AccidentJudge;
import com.ruoyi.workSafetyStandardization.service.IAccidentJudgeService;

/**
 * 评分-重大事故隐患判定Service业务层处理
 *
 * @author pengjie
 * @date 2023-12-15
 */
@Service
public class AccidentJudgeServiceImpl implements IAccidentJudgeService
{
    @Autowired
    private AccidentJudgeMapper accidentJudgeMapper;
    @Autowired
    private MajorConfigMapper majorConfigMapper;

    /**
     * 查询评分-重大事故隐患判定
     *
     * @param accidentJudgeId 评分-重大事故隐患判定主键
     * @return 评分-重大事故隐患判定
     */
    @Override
    public AccidentJudge selectAccidentJudgeByAccidentJudgeId(String accidentJudgeId)
    {
        return accidentJudgeMapper.selectAccidentJudgeByAccidentJudgeId(accidentJudgeId);
    }

    /**
     * 查询评分-重大事故隐患判定列表
     *
     * @param accidentJudge 评分-重大事故隐患判定
     * @return 评分-重大事故隐患判定
     */
    @Override
    public List<AccidentJudge> selectAccidentJudgeList(AccidentJudge accidentJudge)
    {
        return accidentJudgeMapper.selectAccidentJudgeList(accidentJudge);
    }

    /**
     * 新增评分-重大事故隐患判定
     *
     * @param accidentJudge 评分-重大事故隐患判定
     * @return 结果
     */
    @Override
    public int insertAccidentJudge(AccidentJudge accidentJudge)
    {
        accidentJudge.setCreateByName(SecurityUtils.getUsername());
        accidentJudge.setCreateAt(new Date());
        accidentJudge.setCreateBy(SecurityUtils.getUserId().toString());
        accidentJudge.setMajorName(majorConfigMapper.selectMajorConfigByMajorId(accidentJudge.getMajorId()).getMajorName());
        return accidentJudgeMapper.insertAccidentJudge(accidentJudge);
    }

    /**
     * 修改评分-重大事故隐患判定
     *
     * @param accidentJudge 评分-重大事故隐患判定
     * @return 结果
     */
    @Override
    public int updateAccidentJudge(AccidentJudge accidentJudge)
    {
        return accidentJudgeMapper.updateAccidentJudge(accidentJudge);
    }

    /**
     * 批量删除评分-重大事故隐患判定
     *
     * @param accidentJudgeIds 需要删除的评分-重大事故隐患判定主键
     * @return 结果
     */
    @Override
    public int deleteAccidentJudgeByAccidentJudgeIds(String[] accidentJudgeIds)
    {
        return accidentJudgeMapper.deleteAccidentJudgeByAccidentJudgeIds(accidentJudgeIds);
    }

    /**
     * 删除评分-重大事故隐患判定信息
     *
     * @param accidentJudgeId 评分-重大事故隐患判定主键
     * @return 结果
     */
    @Override
    public int deleteAccidentJudgeByAccidentJudgeId(String accidentJudgeId)
    {
        return accidentJudgeMapper.deleteAccidentJudgeByAccidentJudgeId(accidentJudgeId);
    }
}
